package com.chuantou.yuba.api.to;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.annotations.SerializedName;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

/**
 * 省市选择
 * 
 * @author Administrator
 * 
 */
public class CityTO implements Parcelable {
	@SerializedName("id")
	private String id;
	@SerializedName("name")
	private String name;
	@SerializedName("spell")
	private String spell;
	@SerializedName("child")
	private List<CityTO> cities;
	@SerializedName("pid")
	private String pid;

	public CityTO() {

	}

	public CityTO(Parcel source) {
		this.id = source.readString();
		this.name = source.readString();
		this.spell = source.readString();
		this.cities = new ArrayList<CityTO>();
		source.readTypedList(this.cities, CityTO.CREATOR);
		this.pid = source.readString();
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(this.id);
		dest.writeString(this.name);
		dest.writeString(this.spell);
		dest.writeTypedList(this.cities);
		dest.writeString(pid);
	}

	public static final Creator<CityTO> CREATOR = new Creator<CityTO>() {

		@Override
		public CityTO[] newArray(int size) {
			return new CityTO[size];
		}

		@Override
		public CityTO createFromParcel(Parcel source) {
			return new CityTO(source);
		}
	};

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSpell() {
		return spell;
	}

	public void setSpell(String spell) {
		this.spell = spell;
	}

	public String getFirstSpell() {
		return TextUtils.isEmpty(spell) ? "#" : String.valueOf(spell.charAt(0));
	}

	public List<CityTO> getCities() {
		return cities;
	}

	public void setCities(List<CityTO> cities) {
		this.cities = cities;
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

}
